package com.testword.controller;

import com.testword.entity.po.Wordtable;
import com.testword.entity.query.WordtableQuery;
import com.testword.entity.vo.ResponseVO;
import com.testword.service.WordtableService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.util.List;

/**
 * Controller
 */
@RestController
@RequestMapping("/wordtable")

@CrossOrigin(origins = "*",maxAge = 3600)
public class WordtableController extends ABaseController{

	private static final Logger logger = LoggerFactory.getLogger(WordtableController.class);

	@Resource
	private WordtableService wordtableService;

	/**
	 * 分页查询，返回ResponseVO
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(WordtableQuery query) {
		return getSuccessResponseVO(wordtableService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Wordtable bean) {
		this.wordtableService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Wordtable> listBean) {
		this.wordtableService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Wordtable> listBean) {
		this.wordtableService.addOrUpdateBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询
	 */
	@RequestMapping("/getWordtableById")
	public ResponseVO getWordtableById(Integer id) {
		return getSuccessResponseVO(this.wordtableService.getWordtableById(id));
	}

	/**
	 * 根据Id修改
	 */
	@RequestMapping("/updateWordtableById")
	public ResponseVO updateWordtableById(Wordtable bean, Integer id) {
		this.wordtableService.updateWordtableById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteWordtableById")
	public ResponseVO deleteWordtableById(Integer id) {
		this.wordtableService.deleteWordtableById(id);
		return getSuccessResponseVO(null);
	}



}
